package com.zhhs.galaxyott.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.zhhs.galaxyott.R;
import com.zhhs.galaxyott.beans.CategoryBean;
import com.zhhs.galaxyott.utils.Logs;

public class ListFragmentAdapter extends BaseAdapter {

    private Context mContext;
    private List<CategoryBean> mList;
    private int pos;

    public ListFragmentAdapter(Context mContext, List<CategoryBean> mList, int pos) {

        this.mContext = mContext;
        this.mList = mList;
        this.pos = pos;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int postion) {
        return mList.get(postion);
    }

    @Override
    public long getItemId(int postion) {
        return postion;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        Holder holder;
        if (convertView == null) {
            holder = new Holder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.more_movies_list_item, null);

            holder.title_name = (TextView) convertView.findViewById(R.id.title_name);

            convertView.setTag(holder);

        } else {
            holder = (Holder) convertView.getTag();
        }

        holder.title_name.setText(mList.get(position).getName());
        if (position == pos) {
            // holder.title_name.setBackgroundResource(R.drawable.title_normal);
            // holder.title_name.requestFocus();
            Logs.logD("DEBUG_2", "THIS IS pos-->" + pos);
        }

        return convertView;
    }

    class Holder {
        ImageView poster_img;
        TextView title_name;
    }

}
